<include file="public:header" />
<link rel="stylesheet" type="text/css" href="http://img.chachiwang.com/js/calendar/calendar-blue.css"/>
<style type="text/css">
#ad_image img{ 
	width:300px;
}
</style>
<script type="text/javascript" src="http://img.chachiwang.com/js/calendar/calendar.js"></script>
<script type="text/javascript">
	$(function(){
		$("#type").change(function(){
			$(".bill_media").hide();
			$("#ad_"+$(this).val()).show();
		});
		$("#type").change();
		
		//获取版块允许的广告类型
		$("#board_id").change(function(){									  
			var allowtype = $("#board_id option:selected").attr('allowtype');
			var allowtype_arr = allowtype.split("|");
			$("#type option").hide();
			for(i=0; i<allowtype_arr.length; i++) {
			    $("#type option").each(function(){
					if($(this).val() == allowtype_arr[i]){
						$(this).show();
					}
				});
			}
			$("#type").change();
		});
		$("#board_id").change();
	})
</script>
<div class="pad_10">
<form action="{:u('ad/edit')}" method="post" name="myform" id="myform" enctype="multipart/form-data">
<table width="100%" cellpadding="2" cellspacing="1" class="table_form">
	<tr> 
      <th width="80">广告名称 :</th>
      <td><input type="text" name="name" id="name" class="input-text" size="40" value="{$ad_info.name}"></td>
    </tr>
    <tr> 
      <th>广告链接 :</th>
      <td><input type="text" name="url" id="url" class="input-text" size="40" value="{$ad_info.url}"></td>
    </tr>
    <tr>
      <th>广告位 :</th>
      <td>
      	<select name="board_id" id="board_id">
        	<volist name="adboards" id="val" >
        	<option value="{$val.id}" allowtype="{$val.allow_type}" <if condition="$ad_info['board_id'] eq $val['id']">selected="selected"</if>>{$val.name}（{$val.width}*{$val.height}）</option>
        	</volist>
        </select> 
      </td>
    </tr>
    <tr>
      <th>广告类型 :</th>
      <td>
      	<select name="type" id="type">
        	<volist name="ad_type_arr" id="val" >
        	<option value="{$key}" <if condition="$ad_info['type'] eq $key">selected="selected"</if>>{$val}</option>
        	</volist>
        </select> 
      </td>
    </tr>
    <tr id="ad_text" class="bill_media"> 
      <th>文字内容 :</th>
      <td><textarea rows="4" cols="50" name="text" id="text">{$ad_info.code}</textarea></td>
    </tr>
    <tr id="ad_code" class="bill_media"> 
      <th>广告代码 :</th>
      <td><textarea rows="7" cols="65" name="code" id="code">{$ad_info.code}</textarea></td>
    </tr>
    <tr id="ad_image" class="bill_media"> 
      <th>广告图片 :</th>
      <td>	  
		<if condition="$ad_info.type eq 'image'">
			<if condition="$ad_info.code neq ''"><img src="../includes/data/advert/{$ad_info.code}" width="200" height="100" /><br /><br /></if>		
		</if>
      	<input name="image" id="image" type="file" />
      </td>
    </tr>
    <tr id="ad_flash" class="bill_media"> 
      <th>广告动画 :</th>
      <td><input name="flash" id="flash" type="file" /></td>
    </tr>
    <tr> 
      <th>开始时间 :</th>
      <td>
      	<input type="text" name="start_time" id="start_time" class="date" size="22" value="{$ad_info.start_time}">
      	<script language="javascript" type="text/javascript">
			Calendar.setup({
				inputField     :    "start_time",
				ifFormat       :    "%Y-%m-%d %H:%M:%S",
				showsTime      :    'true',
				timeFormat     :    "24"
			});
		</script>
      </td>
    </tr>
    <tr> 
      <th>结束时间 :</th>
      <td>
      	<input type="text" name="end_time" id="end_time" class="date" size="22" value="{$ad_info.end_time}">
        <script language="javascript" type="text/javascript">
			Calendar.setup({
				inputField     :    "end_time",
				ifFormat       :    "%Y-%m-%d %H:%M:%S",
				showsTime      :    'true',
				timeFormat     :    "24"
			});
		</script>
      </td>
    </tr>
    <tr>
        <th>状态 :</th>
        <td>
            <input type="radio" <if condition="$ad_info['status'] eq '1'">checked="checked"</if> value="1" name="status"> 开启 &nbsp;&nbsp;
            <input type="radio" <if condition="$ad_info['status'] eq '0'">checked="checked"</if> value="0" name="status"> 关闭
        </td>
    </tr>
</table>
<input type="hidden" name="id" id="id" value="{$ad_info.id}" />
<input type="submit" name="dosubmit" id="dosubmit" class="dialog" value=" ">
</form>
<script type="text/javascript">
	$(function(){
		$.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'250',height:'50'}, function(){this.close();$(obj).focus();})}});
		
		$("#name").formValidator({onshow:"不能为空",onfocus:"不能为空"}).inputValidator({min:1,onerror:"请填写广告名称"});
	})
</script>
</div>
</body>
</html>